package com.siwei.mes.enums;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

import java.util.Arrays;

/**
 * 星期枚举类
 *
 * @Description: 星期枚举类
 * @Version: 1.0
 * @author: mlchen
 * @date: 2025/3/9 22:14
 */
@Getter
public enum WeekEnum {
    MONDAY("星期一", "1"),
    TUESDAY("星期二", "2"),
    WEDNESDAY("星期三", "3"),
    THURSDAY("星期四", "4"),
    FRIDAY("星期五", "5"),
    SATURDAY("星期六", "6"),
    SUNDAY("星期日", "7"),

    ;
    @ApiModelProperty(value = "周几")
    private String name;
    @ApiModelProperty(value = "对应数字")
    private String code;

    WeekEnum(String name, String code) {
        this.name = name;
        this.code = code;
    }

    /**
     * 根据code查找信息
     *
     * @return
     */
    public static WeekEnum selectByCode(String code) {
        return Arrays.stream(values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
    }
}
